from redis import StrictRedis
import logging


# TODO 项目的配置
class Config(object):
    SECRET_KEY = 'PpfH8HfHmo2WT/0b1wjO8n9URxXLT7ZY4peW2i1cFilygVq/XuDRWPB/UUNc85n5'

    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information27"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 配置最新数据库
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # Redis的配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379
    # Session保存配置
    SESSION_TYPE = "redis"  # 将session 保存在resis中
    # 开启session签名
    SESSION_USE_SIGNER = True
    # 指定 Session 保存的 redis
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)

    # 设置需要过期
    SESSION_PERMANENT = False
    # 设置过期时间
    PERMANENT_SESSION_LIFETIME = 86400 * 2
    LOG_LEVEL = logging.DEBUG


class DevelpmentConfig(Config):
    DEBUG = True

class ProductionConfig(Config):
    DEBUG = False
    LOG_LEVEL = logging.WARNING


class TestingConfig(Config):
    DEBUG = True
    TESTING = True


config = {
    "developmentconfig": DevelpmentConfig,
    "production": ProductionConfig,
    "testing": TestingConfig
}
